import request from '@/utils/request'

export function savePeriod(data) {
    return request({
        url: '/course/chapter-period/save',
        method: 'post',
        data: {
            periodName: data.periodName,
            periodDesc: data.periodDesc,
            periodOriginal: data.periodOriginal,
            periodDiscount: data.periodDiscount,
            courseId: data.courseId,
            chapterId: data.chapterId,
            isFree: data.isFree,
            sort: data.sort
        }
    })
}

export function saveVideo(data) {
    return request({
        url: '/course/chapter-period/cpSaveVideo',
        method: 'post',
        data: {
            id: data.id,
            video: data.video
        }
    })
}

export function saveFile(data) {
    return request({
        url: '/course/chapter-period/cpSaveFile',
        method: 'post',
        data: {
            id: data.id,
            files: data.files
        }
    })
}

export function editPeriod(data) {
    return request({
        url: '/course/chapter-period/cpUpdate',
        method: 'post',
        data: {
            periodName: data.periodName,
            periodDesc: data.periodDesc,
            periodOriginal: data.periodOriginal,
            periodDiscount: data.periodDiscount,
            isFree: data.isFree,
            sort: data.sort
        }
    })
}

export function deletePeriod(data) {
    return request({
        url: '/course/chapter-period/delete',
        method: 'post',
        data: {
            id: data.id
        }
    })
}

export function selectPeriod(data) {
    return request({
        url: '/course/chapter-period/selectByPID',
        method: 'post',
        data: {
            id: data.id
        }
    })
}

export function selectVideo(data) {
    return request({
        url: '/course/chapter-period/selectvideoByPID',
        method: 'post',
        data: {
            id: data.id
        }
    })
}

export function selectFiles(data) {
    return request({
        url: '/course/chapter-period/selectfileByPID',
        method: 'post',
        data: {
            id: data.id
        }
    })
}